package pojo;


import com.fasterxml.jackson.annotation.JsonFormat;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class TableInfo {

    private Integer tableInfoId;
    private Integer tableId;
    private Integer tableInfoNum;
    private Integer tableInfoOrderId;
    private Integer tableInfoWorkerId;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp tableInfoSetupTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp tableInfoLeaveTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp tableInfoBookTime;
    private String tableInfoBookName;

    /*public Timestamp getTableInfoBookTime() {
        return tableInfoBookTime;
    }

    public void setTableInfoBookTime(Timestamp tableInfoBookTime) {
        try {
            if (tableInfoBookTime == null || "".equals(tableInfoBookTime)) {
                return;
            }
            this.tableInfoBookTime = tableInfoBookTime;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
*/
    public String getTableInfoBookTime() {
        if (tableInfoBookTime == null) return null;
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.format(tableInfoBookTime);
        //DateFormat dateFormat = DateFormat.getDateInstance();
        //return dateFormat.format(this.tableInfoBookTime);
    }

    public void setTableInfoBookTime(String tableInfoBookTime) {
        if (tableInfoBookTime == null || "".equals(tableInfoBookTime.trim())) {
            this.tableInfoBookTime = null;
        } else {
            try {
                //DateFormat dateFormat = DateFormat.getDateInstance();
                //this.tableInfoBookTime = new java.sql.Timestamp(dateFormat.parse(tableInfoBookTime).getTime());
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//定义格式，不显示毫秒
                this.tableInfoBookTime=new Timestamp(sdf.parse(tableInfoBookTime).getTime());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }


    public String getTableInfoBookName() {
        return tableInfoBookName;
    }

    public void setTableInfoBookName(String tableInfoBookName) {
        this.tableInfoBookName = tableInfoBookName;
    }

    public String getTableInfoBookPhone() {
        return tableInfoBookPhone;
    }

    public void setTableInfoBookPhone(String tableInfoBookPhone) {
        this.tableInfoBookPhone = tableInfoBookPhone;
    }

    private String tableInfoBookPhone;

    public TableInfo() {
    }

    public Integer getTableInfoId() {
        return tableInfoId;
    }

    public void setTableInfoId(Integer tableInfoId) {
        this.tableInfoId = tableInfoId;
    }


    public Integer getTableId() {
        return tableId;
    }

    public void setTableId(Integer tableId) {
        this.tableId = tableId;
    }


    public Integer getTableInfoNum() {
        return tableInfoNum;
    }

    public void setTableInfoNum(Integer tableInfoNum) {
        this.tableInfoNum = tableInfoNum;
    }


    public Integer getTableInfoOrderId() {
        return tableInfoOrderId;
    }

    public void setTableInfoOrderId(Integer tableInfoOrderId) {
        this.tableInfoOrderId = tableInfoOrderId;
    }


    public Integer getTableInfoWorkerId() {
        return tableInfoWorkerId;
    }

    public void setTableInfoWorkerId(Integer tableInfoWorkerId) {
        this.tableInfoWorkerId = tableInfoWorkerId;
    }


    /*public Timestamp getTableInfoSetupTime() {
        return tableInfoSetupTime;
    }

    public void setTableInfoSetupTime(Timestamp tableInfoSetupTime) {
        try {
            if (tableInfoSetupTime == null || "".equals(tableInfoSetupTime)) {
                return;
            }
            this.tableInfoSetupTime = tableInfoSetupTime;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/

    public String getTableInfoSetupTime() {
        if (tableInfoSetupTime == null) return null;
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.format(tableInfoSetupTime);
       /* DateFormat dateFormat = DateFormat.getDateInstance();
        return dateFormat.format(this.tableInfoSetupTime);*/
    }

    public void setTableInfoSetupTime(String tableInfoSetupTime) {
        if (tableInfoSetupTime == null || "".equals(tableInfoSetupTime.trim())) {
            this.tableInfoSetupTime = null;
        } else {
            try {
                /*SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String time = df.format(tableInfoSetupTime);*/
                Timestamp ts = Timestamp.valueOf(tableInfoSetupTime);
                this.tableInfoSetupTime = ts;
                /*DateFormat dateFormat = DateFormat.getDateInstance();
                this.tableInfoSetupTime = new java.sql.Timestamp(dateFormat.parse(tableInfoSetupTime).getTime());*/
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /*public Timestamp getTableInfoLeaveTime() {
        return tableInfoLeaveTime;
    }

    public void setTableInfoLeaveTime(Timestamp tableInfoLeaveTime) {
        try {
            if (tableInfoLeaveTime == null || "".equals(tableInfoLeaveTime)) {
                return;
            }
            this.tableInfoLeaveTime = tableInfoLeaveTime;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/

    public String getTableInfoLeaveTime() {
        if (tableInfoLeaveTime == null) return null;
        DateFormat dateFormat = DateFormat.getDateInstance();
        return dateFormat.format(this.tableInfoLeaveTime);
    }

    public void setTableInfoLeaveTime(String tableInfoLeaveTime) {
        if (tableInfoLeaveTime == null || "".equals(tableInfoLeaveTime.trim())) {
            this.tableInfoLeaveTime = null;
        } else {
            try {
                DateFormat dateFormat = DateFormat.getDateInstance();
                this.tableInfoLeaveTime = new java.sql.Timestamp(dateFormat.parse(tableInfoLeaveTime).getTime());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public String toString() {
        return "TableInfo{" +
                "tableInfoId=" + tableInfoId +
                ", tableId=" + tableId +
                ", tableInfoNum=" + tableInfoNum +
                ", tableInfoOrderId=" + tableInfoOrderId +
                ", tableInfoWorkerId=" + tableInfoWorkerId +
                ", tableInfoSetupTime=" + tableInfoSetupTime +
                ", tableInfoLeaveTime=" + tableInfoLeaveTime +
                ", tableInfoBookTime=" + tableInfoBookTime +
                ", tableInfoBookName='" + tableInfoBookName + '\'' +
                ", tableInfoBookPhone='" + tableInfoBookPhone + '\'' +
                '}';
    }
}
